package com.meeruu.sg.account.core.domain.model.enums;

import lombok.Getter;

/**
 * @author jiangdawei on 2018/9/4 22:49.
 */
@Getter
public enum StatusEnums {
    ENABLE(1, "有效"),
    DISABLE(0, "无效"),
    ;

    private Integer code;
    private String desc;

    private StatusEnums(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static StatusEnums getByCode(Integer code) {
        if (code == null) {
            return null;
        }

        for (StatusEnums typeEnum : StatusEnums.values()) {
            if (typeEnum.getCode().equals(code)) {
                return typeEnum;
            }
        }
        return null;
    }
}
